Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The npm package 'redent' is used to modify the indentation of a string. It can remove excess indentation and add desired indentation to each line of a given text. This is particularly useful when working with multi-line strings in programming environments where indentation matters, such as in source code or markdown files.
Remove excess indentation
This feature removes excess indentation from a text. The example shows how to use redent to dedent a string to the least indented line.
const redent = require('redent');
const text = ' foo\n bar';
const dedentedText = redent(text, 0);
console.log(dedentedText); // 'foo\n bar'
Add indentation
This feature adds a specified number of spaces to the beginning of each line in the text. The example demonstrates adding 4 spaces of indentation to each line of a string.
const redent = require('redent');
const text = 'foo\nbar';
const indentedText = redent(text, 4);
console.log(indentedText); // ' foo\n bar'
Similar to redent, 'indent-string' allows adding or modifying the indentation of a string. However, it focuses more on adding indentation rather than both adding and removing like redent.
This package is similar to the dedenting aspect of redent. 'strip-indent' is used to remove the leading whitespace from every line in a string, which is useful for cleaning up multi-line strings.
$ npm install --save redent
const redent = require('redent');
redent('\n foo\n bar\n', 1);
//=> '\n foo\n bar\n'
Type: string
Type: number
Default: 0
How many times you want indent
repeated.
Type: string
Default: ' '
String to use for the indent.
MIT © Sindre Sorhus
FAQs
Strip redundant indentation and indent the string
The npm package redent receives a total of 9,441,307 weekly downloads. As such, redent popularity was classified as popular.
We found that redent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.